Attribute VB_Name = "Utilitarios32"
Option Explicit
Const VER_PLATFORM_WIN32s = 0
Const VER_PLATFORM_WIN32_WINDOWS = 1
Const VER_PLATFORM_WIN32_NT = 2
''
Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVERSIONINFO) As Integer
''
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Declare Function SFocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
''
Public Type OSVERSIONINFO
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
End Type
''
Public Type MYVERSION
    lMajorVersion As Long
    lMinorVersion As Long
    lExtraInfo As Long
End Type
Public g_SystemInfo As OSVERSIONINFO
''
Public Function stEncriptarClave(stRClave As String) As String
    Dim stLTemp As String
    Dim stLRta As String
    Dim I As Integer
    Dim j As Integer

    stRClave = UCase$(stRClave)
    I = 1
    While I <> (Len(stRClave) + 1)
        stLTemp = Mid$(stRClave, I, 1)
        j = Asc(stLTemp)
        j = &HA Xor j
        stLRta = stLRta + Chr$(j)
        I = I + 1
    Wend
    stEncriptarClave = stLRta
End Function
Public Sub SrAsignaDllMensajesModificaBD()
    '' Rutina que Asigna el nombre de la dll, de las modificaciones
    '' de la base de datos, al workspace de la aplicacion.
    ''----------------------------
    '' Pasado a Vb 6.0. Alvaro S. Quimbaya C. Marzo 14 2.000.
    ''----------------------------
    Dim stLNombreDLL As String
    ''
    On Local Error GoTo SrAsigDllMenBDErr
    ''
    stLNombreDLL = "m" & App.EXEName & "Bd.dll"
    ''
    Call g_AppWrks.AddResDLL("ModBd", stLNombreDLL)
    g_Sets.Load
    ''
SrAsigDllMenBDEnd:
    Exit Sub
    ''
SrAsigDllMenBDErr:
    ''
    Call g_AppErro.ShowErrorEx(App.EXEName, Err, Error, "Utilitarios32.Bas.SrAsignaDllMensajesModificaBD", "")
    ''
    Resume SrAsigDllMenBDEnd
End Sub
Public Function stOperatingSystemVersion(osinfo As OSVERSIONINFO, bWindowsNT As Boolean) As String
    '' Funcion que determina la version del sistema
    '' operativo que esta corriendo.
    '' Tambien Determina, si esta sobre Windows NT.
    Dim retvalue As Integer
    Dim stLDescripcion As String
    Dim stLServicePack As String
    ''
    On Local Error GoTo ErrorstOperatingSystemVersion
    ''
    bWindowsNT = False
    stLDescripcion = ""
    stLServicePack = ""
    ''
    osinfo.dwOSVersionInfoSize = 148
    osinfo.szCSDVersion = Space$(128)
    retvalue = GetVersionExA(osinfo)
    ''
    If osinfo.dwMajorVersion = 4 Then
        If osinfo.dwPlatformId = VER_PLATFORM_WIN32_NT Then
            bWindowsNT = True
            stLDescripcion = "Windows NT version : "
            stLServicePack = osinfo.szCSDVersion
        ElseIf osinfo.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
            stLDescripcion = "Windows 95 version : "
        End If
    Else
        stLDescripcion = "Windows version : "
    End If
    stLDescripcion = stLDescripcion & osinfo.dwMajorVersion _
    & "." & osinfo.dwMinorVersion & " " & stLServicePack
    ''
    stOperatingSystemVersion = stLDescripcion
    ''
stOperatingSystemVersionEnd:
    Exit Function
    ''
ErrorstOperatingSystemVersion:
    ''
    stOperatingSystemVersion = ""
    ''
    Call g_AppErro.ShowErrorEx(App.EXEName, Err, Error, "Utilitarios32.Bas.stOperatingSystemVersion", " ")
    ''
    Resume stOperatingSystemVersionEnd
End Function
''
Public Function bValidarUnico32EnBas(Optional inRTipoRestaura As Integer) As Boolean
    '' Valida que la aplicacion no exista otra ventana
    '' con el mismo nombre de la aplicacion
    ''-------------------------------------------
    '' Alvaro S. Quimbaya C. Junio 22 2.000.
    ''-------------------------------------------
    Dim stLTitulo As String
    Dim bnLX As Boolean
    ''
    On Error GoTo bValidarUnico32EnBasErr
    ''
    stLTitulo = g_AppWrks.Caption & "-" & g_AppWrks.LicensedTo
    ''
    bnLX = bChequeaUnico32EnBas(stLTitulo, inRTipoRestaura)
    ''
    bValidarUnico32EnBas = bnLX
bValidarUnico32EnBasEnd:
    Exit Function
    ''
bValidarUnico32EnBasErr:
    ''
    bValidarUnico32EnBas = False
    Call g_AppErro.ShowErrorEx(App.EXEName, Err, Error, "Utilitarios32.Bas.bValidarUnico32EnBas", "")
    ''
    Resume bValidarUnico32EnBasEnd
End Function
Public Function bChequeaUnico32EnBas(stNombreForma As String, Optional inRTipoRestaura As Integer) As Boolean
    ''
    '' Funcion que halla el manejador de la ventana.
    ''-------------------------------------------
    '' Alvaro S. Quimbaya C. Junio 22 2.000.
    ''-------------------------------------------
    Dim lnLManejador As Long
    Dim lnLX As Long
    ''
    On Error GoTo bChequeaUnico32EnBasErr
    ''
    lnLManejador = FindWindow(0&, stNombreForma)
    ''
    If lnLManejador = 0 Then
        '
        bChequeaUnico32EnBas = True
    Else
        ''
        If inRTipoRestaura <= 0 Then
            inRTipoRestaura = vbMaximizedFocus
        End If
        DoEvents
        DoEvents
        lnLX = ShowWindow(lnLManejador, vbMaximizedFocus)
        lnLX = SFocus(lnLManejador)
        ''
        bChequeaUnico32EnBas = False
    End If
bChequeaUnico32EnBasEnd:
    Exit Function
    ''
bChequeaUnico32EnBasErr:
    ''
    bChequeaUnico32EnBas = False
    Call g_AppErro.ShowErrorEx(App.EXEName, Err, Error, "Utilitarios32.Bas.bChequeaUnico32EnBas", "")
    ''
    Resume bChequeaUnico32EnBasEnd
End Function
Public Function stEncriptarClaveNew(stRClave As String) As String
    Dim stLTemp As String
    Dim stLRta As String
    Dim I As Integer
    Dim j As Integer

    stRClave = UCase$(stRClave)
    I = 1
    While I <> (Len(stRClave) + 1)
        stLTemp = Mid$(stRClave, I, 1)
        j = Asc(stLTemp)
        j = &HA Xor j
        stLRta = stLRta + Chr$(j)
        I = I + 1
    Wend
    ''***-------------------***
    '' ASQC Febrero 4 2.002.
    ''***-------------------***
    '' Falto esto de la rutina de Vb 30.
    ''stEncriptarClaveNew = stLRta
    ''Jhon Gaviria /Alvaro Quimbaya Junio 21/1999. Se quita el caracter ;
    ''ya que genera conflicto con el PWD de SQL cuando se intenta recuperar.
    stLRta = stCambiaCadena(stLRta, ";", "X")
    stEncriptarClaveNew = stLRta
    ''***-------------------***
    '' Fin ASQC Febrero 4 2.002.
    ''***-------------------***
End Function
Public Function stCambiaCadena(stRCadenaMadre As String, stRCadenaBuscada As String, stRCadenaRemplaza As String)
    '' ASQC Febrero 4 2.002.
    '' Rutina copiada de Vb 30.
    Dim inLPosArranque As Integer
    Dim inLTamano As Integer
    Dim stLCadenaInicio As String, stLCadenaFinal As String
    Dim stLTemporal As String
    Dim stLCadenaCambiada As String
    ''
    stLCadenaCambiada = stRCadenaMadre
    inLPosArranque = InStr(stRCadenaMadre, stRCadenaBuscada)
    stLTemporal = stRCadenaMadre
    Do While inLPosArranque > 0
        inLTamano = Len(stRCadenaBuscada)
        stLCadenaInicio = Mid$(stLTemporal, 1, inLPosArranque - 1)
        stLCadenaFinal = Mid$(stLTemporal, (inLPosArranque + inLTamano))
        stLTemporal = stLCadenaInicio + stRCadenaRemplaza + stLCadenaFinal
        inLPosArranque = InStr(stLTemporal, stRCadenaBuscada)
        stLCadenaCambiada = Trim$(stLTemporal)
    Loop
    ''
    stCambiaCadena = stLCadenaCambiada
End Function

